/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vista;

import dao.BebidaDao;
import dao.GuarnicionDao;
import dao.MenuDao;
import daoimp.BebidaDaoImp;
import daoimp.GuarnicionDaoImp;
import daoimp.MenuDaoImp;
import java.util.ArrayList;
import javax.swing.table.DefaultTableModel;
import modelo.dominio.Bebida;
import modelo.dominio.Guarnicion;
import modelo.dominio.Menu;

/**
 *
 * @author Pablo
 */
public class UIMenu extends javax.swing.JFrame {
      ArrayList<Bebida> listaBebidas = new ArrayList<Bebida>();
      ArrayList<Guarnicion> lista = new ArrayList<Guarnicion>();
      ArrayList<Menu> listaMenu = new ArrayList<Menu>();
         MenuDao md = new MenuDaoImp();
         GuarnicionDao gd = new GuarnicionDaoImp();
         BebidaDao bd = new BebidaDaoImp();
    /**
     * Creates new form UIMenu
     */
    public UIMenu() {
        initComponents(); 
        txtCantidad.setText("1");
        listaMenu=md.getAll();
        lista=gd.getAll();
        listaBebidas=bd.getAll();      
        this.cargarMenu();
        this.cargarGuarnicion();
        this.cargarBebida();   
        
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        cmbMenu = new javax.swing.JComboBox();
        cmbGuarnicio = new javax.swing.JComboBox();
        cmbBebida = new javax.swing.JComboBox();
        btnPedir = new javax.swing.JButton();
        btnLimpiar = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        tblPedido = new javax.swing.JTable();
        txtMesa = new javax.swing.JTextField();
        txtTotal = new javax.swing.JTextField();
        cmbVolumen = new javax.swing.JComboBox();
        txtCantidad = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        mnuSalir = new javax.swing.JMenu();
        itmNUsuario = new javax.swing.JMenuItem();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        mnuMenu = new javax.swing.JMenuItem();
        mnuGestionBebidas = new javax.swing.JMenuItem();
        mnuGuarnicion = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        cmbMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbMenuActionPerformed(evt);
            }
        });

        cmbGuarnicio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbGuarnicioActionPerformed(evt);
            }
        });

        cmbBebida.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Escoja Bebida" }));

        btnPedir.setText("Pedir");
        btnPedir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPedirActionPerformed(evt);
            }
        });

        btnLimpiar.setText("Limpiar");
        btnLimpiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLimpiarActionPerformed(evt);
            }
        });

        tblPedido.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        tblPedido.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "PEDIDO", "PRECIO"
            }
        ));
        jScrollPane2.setViewportView(tblPedido);

        txtMesa.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        txtMesa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtMesaActionPerformed(evt);
            }
        });

        txtTotal.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N

        cmbVolumen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbVolumenActionPerformed(evt);
            }
        });

        txtCantidad.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        txtCantidad.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtCantidadActionPerformed(evt);
            }
        });

        jLabel1.setText("Cantidad");

        jLabel2.setText("Mesa");

        jLabel3.setText("Tamaño");

        jLabel4.setText("Menú");

        jLabel5.setText("Guarnición");

        jLabel6.setText("Bebida");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(42, 42, 42)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(btnPedir, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(btnLimpiar, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(cmbBebida, 0, 137, Short.MAX_VALUE)
                                        .addComponent(cmbMenu, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                    .addComponent(jLabel4)
                                    .addComponent(jLabel5)
                                    .addComponent(jLabel6)
                                    .addComponent(cmbGuarnicio, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(42, 42, 42)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel1)
                                    .addComponent(txtMesa, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel3)
                                    .addComponent(cmbVolumen, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel2)
                                    .addComponent(txtCantidad, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(47, 47, 47)
                        .addComponent(txtTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 287, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(26, 26, 26)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 380, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(330, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(17, 17, 17)
                                .addComponent(jLabel4))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(25, 25, 25)
                                .addComponent(jLabel1)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtCantidad, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cmbMenu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(jLabel2))
                        .addGap(17, 17, 17)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(cmbGuarnicio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtMesa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(jLabel3))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(cmbBebida, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cmbVolumen, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(81, 81, 81)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(btnPedir)
                            .addComponent(btnLimpiar)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(42, 42, 42)
                        .addComponent(txtTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(50, 50, 50)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(223, Short.MAX_VALUE))
        );

        mnuSalir.setText("Archivo");
        mnuSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnuSalirActionPerformed(evt);
            }
        });

        itmNUsuario.setText("Nuevo usuario");
        itmNUsuario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itmNUsuarioActionPerformed(evt);
            }
        });
        mnuSalir.add(itmNUsuario);

        jMenuItem1.setText("Salir");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        mnuSalir.add(jMenuItem1);

        jMenuBar1.add(mnuSalir);

        jMenu2.setText("Resto");

        mnuMenu.setText("Gestión Menu");
        mnuMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnuMenuActionPerformed(evt);
            }
        });
        jMenu2.add(mnuMenu);

        mnuGestionBebidas.setText("Gestión Bebidas");
        mnuGestionBebidas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnuGestionBebidasActionPerformed(evt);
            }
        });
        jMenu2.add(mnuGestionBebidas);

        mnuGuarnicion.setText("Gestión Guarniciones");
        mnuGuarnicion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnuGuarnicionActionPerformed(evt);
            }
        });
        jMenu2.add(mnuGuarnicion);

        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(30, 30, 30)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void mnuMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnuMenuActionPerformed
        // TODO add your handling code here:
       ABMLMenu abmlm = new ABMLMenu(this, true);       
       abmlm.setVisible(true);
       abmlm.setLocationRelativeTo(this);
    }//GEN-LAST:event_mnuMenuActionPerformed

    private void mnuGestionBebidasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnuGestionBebidasActionPerformed
        // TODO add your handling code here:
        ABMLBebida abmlb = new ABMLBebida(this, true);
        abmlb.setVisible(true);
        abmlb.setLocationRelativeTo(this);
    }//GEN-LAST:event_mnuGestionBebidasActionPerformed

    private void mnuGuarnicionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnuGuarnicionActionPerformed
        // TODO add your handling code here:
        ABMLGuarnicion ag = new ABMLGuarnicion(this, true);
        ag.setVisible(true);
        ag.setLocationRelativeTo(this);
        
        
    }//GEN-LAST:event_mnuGuarnicionActionPerformed

    private void mnuSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnuSalirActionPerformed
        // TODO add your handling code here:
     
    }//GEN-LAST:event_mnuSalirActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        // TODO add your handling code here:
           System.exit(0);
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void cmbMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbMenuActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cmbMenuActionPerformed

    private void btnPedirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPedirActionPerformed
        // TODO add your handling code here:
                    this.pedir();
    }//GEN-LAST:event_btnPedirActionPerformed

    private void btnLimpiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLimpiarActionPerformed
        // TODO add your handling code here:
                    this.limpiar();
    }//GEN-LAST:event_btnLimpiarActionPerformed

    private void cmbVolumenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbVolumenActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cmbVolumenActionPerformed

    private void cmbGuarnicioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbGuarnicioActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cmbGuarnicioActionPerformed

    private void txtCantidadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtCantidadActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtCantidadActionPerformed

    private void txtMesaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtMesaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtMesaActionPerformed

    private void itmNUsuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itmNUsuarioActionPerformed
        // TODO add your handling code here:
        ABMLUsuario aUsu = new ABMLUsuario(this, true);
        aUsu.setVisible(true);
        aUsu.setLocationRelativeTo(this);
    }//GEN-LAST:event_itmNUsuarioActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(UIMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(UIMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(UIMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(UIMenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new UIMenu().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnLimpiar;
    private javax.swing.JButton btnPedir;
    private javax.swing.JComboBox cmbBebida;
    private javax.swing.JComboBox cmbGuarnicio;
    private javax.swing.JComboBox cmbMenu;
    private javax.swing.JComboBox cmbVolumen;
    private javax.swing.JMenuItem itmNUsuario;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JMenuItem mnuGestionBebidas;
    private javax.swing.JMenuItem mnuGuarnicion;
    private javax.swing.JMenuItem mnuMenu;
    private javax.swing.JMenu mnuSalir;
    private javax.swing.JTable tblPedido;
    private javax.swing.JTextField txtCantidad;
    private javax.swing.JTextField txtMesa;
    private javax.swing.JTextField txtTotal;
    // End of variables declaration//GEN-END:variables

    private void cargarMenu() {    
          for(Menu m  : listaMenu){
              cmbMenu.addItem(m.getNombre());
          }
            
    }

    private void cargarGuarnicion() {     
        for(Guarnicion g : lista){
            cmbGuarnicio.addItem(g.getNombre());
        }
    
    }

    private void cargarBebida() {    
            for(Bebida b : listaBebidas){
                cmbBebida.addItem(b.getNombre()+" "+b.getVolumen());
            }
        
    }
    /*
     * "Pedir" Una vez seleccionado el menú y la guarnicion, el precio de dicho menú
     * más el nombre del mismo y la guarnición son reflejados en la tabla pedidos y el 
     * total de todo el pedido se va acumulando en txtTotal.
     */
    private void pedir() {
        DefaultTableModel modelo = (DefaultTableModel) tblPedido.getModel();
        String datos[] = new String[2];
        String nomM = (String) this.cmbMenu.getSelectedItem();
        String nomB = (String) this.cmbBebida.getSelectedItem();
        String gu  = (String) this.cmbGuarnicio.getSelectedItem(); 
        int cant = Integer.parseInt(txtCantidad.getText());
        double total=0;
        for(int i=0; i<listaMenu.size(); i++){
            for(int j=0; j<lista.size();j++){
            if(nomM.equals(listaMenu.get(i).getNombre()) && gu.equals(lista.get(j).getNombre())){
                datos[0]=listaMenu.get(i).getNombre()+" con "+lista.get(j).getNombre(); 
                datos[1]=String.valueOf(listaMenu.get(i).getPrecio()*cant);
                
            }
            }
        }
                modelo.addRow(datos);        
         for(int y=0; y<tblPedido.getRowCount(); y++){
             String p = (String) tblPedido.getValueAt(y, 1);
             double pv=Double.parseDouble(p);
             total=total+pv;
             txtTotal.setText(String.valueOf(total));
             /*
              * redondear total
              */
            
         }
    }


    private void limpiar() {
         DefaultTableModel modelo = (DefaultTableModel) tblPedido.getModel();
                while(tblPedido.getRowCount() != 0)
                    modelo.removeRow(0);
                txtCantidad.setText("1");
    }
}
